package com.quanfu.ioc_04;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JavaBean {
    /**
     * <bean id=""  class=""
     *      <property name="name" value="二狗子"
     */



    // 方案一：直接赋值
    // 方案二：注解赋值 @Value()注解  读取外部配置
    //        默认值语法 @Value("${key:value默认值}")
    private String name = "二狗子";

    @Value("19")
    private int age;

    @Value("${jdbc.username:admin}")
    private String username;
    @Value("${jdbc.password}")
    private String password;

    @Override
    public String toString() {
        return "JavaBean{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
